﻿@{
    Layout = null;
    var data = (Apps.Web.Model.BarLabelRotationModel)Model;
    string SeriesStr = "";
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ECharts</title>
    <script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
</head>
<body style="margin:0 0 0 0">
    <div id="charts" style="width:99%;height:230px;"></div>
    <script src="~/Scripts/echarts.min.js"></script>
    <script type="text/javascript">
        var labelOption = {
            normal: {
                show: true,
                rotate: 90,
                align: 'left',
                verticalAlign: 'middle',
                position: 'insideBottom',
                distance: 15,
                formatter: '{c}  {name|{a}}',
                fontSize: 10,
                rich: {
                    name: {
                        textBorderColor: '#fff'
                    }
                }
            }
        };

        option = {
            color: ['#87cefa', '#ff7f50'],
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            toolbox: {
                feature: {
                    magicType:{show:true,type:['line','bar']},
                    saveAsImage: {}
                }
            },
            grid:{
                x: 60,
                y: 25,
                x2: 5,
                y2: 25,
            },
            legend: {
                data: @Html.Raw(data.Legend)
            },
            calculable: true,
            xAxis: [
                {
                    axisLabel:{interval:0},
                    type: 'category',
                    axisTick: { show: false },
                    data: @Html.Raw(data.xAxisData)
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            series: [
                @foreach(var item in data.Series)
                {
                    if (string.IsNullOrWhiteSpace(SeriesStr))
                    {
                        SeriesStr += "{name: '" + item.name + "', type: 'bar', data: " + item.data + "}";
                    }
                    else
                    {
                        SeriesStr += ",{name: '" + item.name + "', type: 'bar', data: " + item.data + "}";
                    }
                }
                @Html.Raw(SeriesStr)
            ]
        };

        $(function () {
            var myChart = echarts.init(document.getElementById('charts'));
            myChart.setOption(option, true);
        })
    </script>
</body>
</html>
